package com.atshiyou.dao;

import com.atshiyou.bean.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface StudentDao {
    //增删改查
    @Insert("insert into student(stuname,stuage,gid) values (#{stuName},#{stuAge},#{gid})")
    @Options(useGeneratedKeys = true,keyProperty = "stuId") //获取新增数据的id
    public int insertStu(Student student);

    //删除
    @Delete("")
    public int delete(int sid);

    //修改
    @Update("update student set stuname=#{stuName},stuage=#{stuAge},gid=#{gid} where stuid=#{stuId}")
    public int updateStu(Student student);

    //查询
    @Select("select * from student")
    public List<Student> findAll();

    @Select("select count(*) from student")
    public int totalCount();
    //计算出ID的最大值，最小值，平均值

    @Select("select Max(stuid) max,Min(stuid) min,Avg(stuid) avg from student")
    public Map total2();




}
